///创建星星函数
float Star(vec2 uv, float flare) {
    float d = length(uv);
    float m = 0.03 / d;
    float r = max(0.0, 1.0 - abs(uv.x * uv.y * 1000.0));
    m += r * flare;
    return m * smoothstep(0.8, 0.2, d);
}

mat2 Rot(float a) {
    float s = sin(a);
    float c = cos(a);
    return mat2(c, -s, s, c);
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
    // Normalized pixel coordinates (from 0 to 1)
    vec2 uv = fragCoord / iResolution.xy;
    uv*=10.;
    uv = fract(uv);
    //校准vec2(0,0)点为中心
    uv += vec2(-0.5, -0.5);

//强制校准比例防止变形
    float lerp = iResolution.x / iResolution.y;
    uv.x *= lerp;

//创建一个星星
    vec3 col = vec3(0.);
    for(int s = 0; s < 4; s++) {
        col += vec3(Star(uv * Rot(iTime + float(s)), 0.6 * sin(float(s) / 4.)));
    }
    // Time varying pixel color
    // vec3 col = 0.5 + 0.5 * cos(iTime + uv.xyx + vec3(0, 2, 4));

    // Output to screen
    fragColor = vec4(col, 1.0);
}